package com.hcss.common.codegenerator;

import com.hcss.generator.MybatisGeneratorController;
import com.hcss.generator.MybatisGeneratorPar;
import com.hcss.generator.MybatisGeneratorService;
import com.hcss.generator.MybatisGeneratorServiceImpl;
import com.hcss.generator.constants.TemplateGenerateConstant;
import com.hcss.generator.enums.DatasourceType;

/**
 * @描述: 根据模板生成业务Controller、Service、ServiceImpl文件
 * @作者: xuqian
 * @创建日期: 2018-07-11 16:59
 * @公司 浙江鸿程计算机系统有限公司
 */
public class RunGenerateMain {

    public static void main(String[] args) {
        String basePackagePath = "com.hcss.bus.fhl",// 引用java类的包路径
                baseBusinessPackagePath = "com.hcss.bus.fhl",// 生成java类的包路径
                modelClass = "HcFhl", // 引用java类的基础类名
                businessName = "fhl",// 生成业务类型名
                auth = "zhulu";// 文件作者
        try {
            // 设置常量
            TemplateGenerateConstant.author = auth;// 文件作者
            TemplateGenerateConstant.datasourceType = DatasourceType.oracle.getType();// 数据库类型
            TemplateGenerateConstant.branch = "/uuid";// id是否用uuid

            // par
            MybatisGeneratorPar.generatorParFile(modelClass, basePackagePath, businessName);
            // service
            MybatisGeneratorService.getInstance().generateServiceFile(modelClass, basePackagePath, baseBusinessPackagePath, businessName);
            // serviceImpl
            MybatisGeneratorServiceImpl.getInstance().generateServiceImplFile(modelClass, basePackagePath, baseBusinessPackagePath, businessName);
            // controller
            MybatisGeneratorController.getInstance().generateControllerFile(modelClass, basePackagePath, baseBusinessPackagePath, businessName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
